<template>
	<view>
		<view style="border: 1rpx solid darkgray;">
			<view style="margin: 10px;">计划编号: {{formCode}}</view>
		</view>
		
		<uni-card :is-shadow="true" is-full style="margin-top: 15px;">
			<uni-list>
				<uni-list-item title="线路" :rightText="line" />
				<uni-list-item title="登记车站" :rightText="regiserByStation" />
				<uni-list-item title="作业区段" :rightText="workSection" />
				<uni-list-item title="施工内容" :rightText="workContent" />
				<uni-list-item title="更新时间" :rightText="formDate" />
				<uni-list-item title="施工负责人" :rightText="manageBy" />
			</uni-list>
		</uni-card>
		
		<view>
		<form @submit="onSubmit">
		  <view>晚登记说明:</view>
		  <input type="text" name="laterPointRemark" v-model="formData.laterPointRemark" />
          <button form-type="submit" type="primary" style="margin: 10px;">提交</button>
	    </form>
	    </view>
	</view>
</template>

<script>
	import axios from "axios"
	import { title } from "process";
	export default {
		data() {
			return {
				formCode: "", // 从数据库获取的计划编号
				line: "", // 从数据库获取的线路
				regiserByStation: "", // 从数据库获取的车站
				workSection: "", // 从数据库获取的施工范围
				workContent: "", // 从数据库获取的施工内容
				formDate: "", // 从数据库获取的更新时间
				manageBy: "" ,// 从数据库获取的施工负责人
				formData:{
					laterPointRemark:''
				}
	            };
				
		},
		methods: {
			fetchDataFromBackend() {
						uni.request({
							url: 'http://localhost:82/constructionRequestBase/management/35c22209-5bec-4a6c-8b01-02c729f759e8', // 替换为实际的后端API地址
							method: 'GET',
							success: (res) => {
								console.log(res.data);
								// 从后端成功获取数据后，更新前端数据
								this.formCode = res.data.data.formCode;
								this.line = res.data.data.lineText;
								this.regiserByStation = res.data.data.regiserByStation;
								this.workSection = res.data.data.workSection;
								this.workContent = res.data.data.workContent;
								this.formDate = res.data.data.formDate;
								this.manageBy = res.data.data.manageBy;
							},
							fail: (err) => {
							   console.error('Failed to fetch data from backend:', err);
							},
						});
					},
					onSubmit(e) {
					      e.preventDefault(); // 防止表单默认提交
						  console.log("test")
					      // console.log(e.target.detail.value);
					      // this.obj = e.target.detail.value;
						  axios.post("http://localhost:82/workOrderReview/management",this.formData)
						  .then((data)=>{
							  console.log(data)
							  uni.navigateTo({
							              url: '/pages/constructionprocess/constructionprocess?update4=true'
							            });
						  }).catch((err)=>{
							  console.log(err)
						  })
						  
					    },
				},
				created() {
					this.fetchDataFromBackend(); // 在组件创建时从后端获取数据
				}
		}
		
</script>

<style>

</style>
